package com.gagakuai.bpm.domian.query.camunda;


import com.gagakuai.bpm.domian.vo.camunda.PageVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*
 * bpm
 */
@Data
@Accessors(chain = true)
@ApiModel
public class WorkflowQuery extends PageVo {

    /*
     * 流程名称
     */
    @ApiModelProperty(name = "processDefinitionName", value = "流程名称")
    private String processDefinitionName;

    /*
     * 任务名称
     */
    @ApiModelProperty(name = "taskName", value = "任务名称")
    private String taskName;

    /*
     * 候选组（以逗号分隔）
     */
    @ApiModelProperty(name = "candidateGroups", value = "候选组（以逗号分隔）")
    private String candidateGroups;

    /*
     */
    @ApiModelProperty(name = "candidateUsers", value = "候选用户（以逗号分隔）")
    private String candidateUsers;

    /*
     * 拥有人
     */
    @ApiModelProperty(name = "owner", value = "拥有人")
    private String owner;

    /*
     * 办理人
     */
    @ApiModelProperty(name = "assignee", value = "代理人")
    private String assignee;

    /*
     * 流程发起人
     */
    @ApiModelProperty(name = "startUser", value = "流程发起人")
    private String startUser;

    /*
     * 流程/任务是否结束
     */
    @ApiModelProperty(name = "isFinished", value = "流程/任务是否结束")
    private String isFinished;

    @ApiModelProperty(name = "tenantId", value = "用户ID")
    private String tenantId;

    @ApiModelProperty(name = "taskId", value = "任务ID")
    private String taskId;

    /*
     * 获取字符串列表
     *
     * @return 列表
     */
    public List<String> getGroupIdList() {
        List<String> ids = new ArrayList<>();
        if (StringUtils.isNotBlank(this.candidateGroups)) {
            String[] idarr = StringUtils.split(this.candidateGroups, ",");
            Collections.addAll(ids, idarr);
        }
        return ids;
    }

    /*
     * 获取候选用户ID列表
     *
     * @return id列表
     */
    public List<String> getUserIdList() {
        List<String> ids = new ArrayList<>();
        if (StringUtils.isNotBlank(this.candidateUsers)) {
            String[] idarr = StringUtils.split(this.candidateUsers, ",");
            Collections.addAll(ids, idarr);
        }
        return ids;
    }
}
